<style type="text/css">
	.txtTitle{font-weight:bold;}
</style>
<?

if($_REQUEST['paynow'] >= 1)
{	include "acceptorder.php";
	//include "acceptandsendmail.php";
	$valuearray['odn_status'] = 1;
	$valuearray['date_accept'] = date("Y-m-d");
	Qupdate("ordernow","",$valuearray," odn_cartid ='".$_REQUEST['odn_cartid']."'");

	exit("<script type=\"text/javascript\">window.location='?body=order&status=1';</script>");

}
if($_REQUEST['reject'] >= 1)
{	
	
	mysql_query("delete from ordernow where odn_cartid = '".$_REQUEST['odn_cartid']."' ") or die(mysql_error());

	exit("<script type=\"text/javascript\">window.location='?body=order&status=0';</script>");

}

?>

<p style="clear:both;">

<h1 style='color:#9999CC;font-size:18px;'><b>.:: <? if($_REQUEST[status]==0){?>รายการสั่งซื้อมาใหม่<?}else{?>รายการสั่งซื้อที่อนุมัติ<?}?> ::.</b></h1><br><br>
<?
$total = 0;
/*$r1 = Q2("select *  from ordernow,product,customer where product.pd_id = ordernow.pd_id and odn_status = '".$_REQUEST['status']."' and odn_cartid ='".$_REQUEST['odn_cartid']."' and ordernow.odn_cust=customer.cust_id   order by odn_id desc ");*/
$r1 = Q2("select *  from ordernow,product where product.pd_id = ordernow.pd_id and odn_status = '".$_REQUEST['status']."' and odn_cartid ='".$_REQUEST['odn_cartid']."' order by odn_id desc ");
$rx = $r1;
foreach($r1 as $r)
{
	$pic = Q1(" select img_pic from images where img_id='".$r['odn_img']."' order by img_id asc");
	
								if($pic['0'] != ""){
									$pic['0'] = "../imgs/".$pic['0'];
								}else{
									$pic['0'] = "../images/no_photo.gif";
								}
	?>
	
	<div style="height:auto;padding:5px 5px 5px 5px ;margin:10px 0px 10px 0px; border:solid 1px #CCC;">
            <div style = "float:left; width:200px; height:auto; border:dashed 1px #CCC;">
                	<img src="<?=$pic[0]?>" height="100" style = "display:block;margin:0 auto;" >
            </div>
            <div  style = "float:left;margin:10px 0px 0px 10px; line-height:20px;">
            		<span class = "txtTitle">ชื่อ : </span><?=$r['pd_name2']?> <br /> 
                    <span class = "txtTitle">ราคา : </span><?=number_format($r['pd_price2'] , 2)?> บาท  <br/>
                    <span class = "txtTitle">จำนวน : </span><?=$r[odn_size]?> รายการ
            </div>
            <div style = "clear:both"></div>
	</div>	
	
	<?
	$total += $r['pd_price']*$r[odn_ea];

}

?>
</p>

<p style="clear:both;">
<!--<h2 style="text-align:center;">Total amount price <br />
 <?=number_format($total)?></h2>-->
 

 <!--<br />
<br />
<center>.:: Customer Details ::.</center><br
>
<table align=center width="60%" style='border:1px solid #CCCCCC' >
	<tr>
		<td colspan=2><br></td>
	</tr>
	<tr>
		<td width='100' align=right>name : </td>
		<td><?=$rx[0][cust_firstname]." ".$rx[0][cust_lastname]?></td>
	</tr>
	<tr>
		<td width='100' align=right>address : </td>
		<td><?=$rx[0][cust_address]?></td>
	</tr>
	<tr>
		<td width='100' align=right>Tel : </td>
		<td><?=$rx[0][cust_tel]?></td>
	</tr>
	<tr>
		<td width='100' align=right>Email : </td>
		<td><?=$rx[0][cust_email]?></td>
	</tr>
	<tr>
		<td colspan=2><br></td>
	</tr>
</table>-->
<br />
<? if($_REQUEST['status'] == 0): ?> 
<table style='width:100%;' align=center>
	<tr>
		<td align=center style='font-size:24px;font-weight:bold;color:green;'>
<a href="?body=orderview&odn_cartid=<?=$_REQUEST['odn_cartid']?>&status=<?=$_REQUEST['status']?>&paynow=1" onclick="javascript:if(confirm('To accept this order ?')== true) return true;else return false;" style='color:green'>Accept</a>
		</td>
		<td align=center style='font-size:24px;font-weight:bold;color:red;'>
  <a href="?body=orderview&odn_cartid=<?=$_REQUEST['odn_cartid']?>&status=<?=$_REQUEST['status']?>&reject=1" onclick="javascript:if(confirm('To Reject this order ?')== true) return true;else return false;" style='color:red'>Reject</a>
		</td>
	</tr>
 </table>
 <? endif; ?>
</p>

<div style="clear:both;"></div>